@extends('admin.layouts.app')
@section('css')
<link rel="stylesheet" href="{{ asset('assets/plugins/treegrid/css/jquery.treegrid.css')}}">
<link rel="stylesheet" href="{{ asset('assets/css/documentselecttree.min.css') }}">
<link rel="stylesheet" href="{{ asset('assets/plugins/select2/css/select2.min.css') }}" />
@endsection
@section('content')

                        <!-- Page-Title -->
                        <div class="row">
                            <div class="col-sm-12">
                                <h4 class="page-title">平台管理</h4>
                                <ol class="breadcrumb">
                                    <li><a href="#">系统</a></li>
                                    <li><a href="{{url('zadmin/role')}}">角色管理</a></li>
                                    <li class="active">修改角色</li>
                                </ol>
                            </div>
                        </div>
                        
                        <div class="row">
                        	<div class="col-lg-12">
                        		<div class="card-box">
                            <h2 class="m-t-0 header-title">配置角色权限</h2>
                            <hr/>
                             
                              @include('admin.common.error')
                        			<div class="row">
			                        	<div class="col-md-12">
                                  <form class="form-horizontal" role="form" action="{{url('zadmin/role/'.$data->id)}}" method="post">{{ method_field('PUT') }}

                                              <div class="form-group">
                                                  <label class="col-md-2 control-label">角色名</label>
                                                  <div class="col-md-10">
                                                      <input type="text" class="form-control" name="name" required="" value="{{$data->name}}" >
                                                  </div>
                                              </div>

                                  <div class="form-group">
                                     <label class="col-md-2 control-label">菜单/权限</label>
                                    <div class="col-md-10">
                                       <table id="example2" class="table  table-striped tree">
                            <thead>
                            
                            </thead>
                            <tbody>
                            @foreach($menus as $k=>$data)

                                <tr class="treegrid-{{$data->id}} {{$data->parent_id?'treegrid-parent-'.$data->parent_id:''}}">
                                    <td>

                                    <input type="checkbox" value="{{ $data->id }}" name="menu_ids[]" {{in_array($data->id,$role_menu_arr)?'checked':''}}>&nbsp 
                                   <strong>{{ $data->name }}</strong>
                                   &nbsp;&nbsp;&nbsp;
                                   @foreach($data->permission as $p)

                                   <input type="checkbox" value="{{ $p->id }}" name="permission_ids[]" data-menuid="{{$data->id}}" {{in_array($p->id,$role_permission_arr)?'checked':''}} />{{$p->name}}
                                   &nbsp;&nbsp;
                                   @endforeach
                                   
                                 
                                 </td>  
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                                    </div>
                                  </div>            

                                              

                                              

                                              <div class="form-group text-center">
                                                  
                                                  <button type="submit" class="btn btn-info waves-effect waves-light">保存</button>
                                              </div>
                                              
                                              
                             {{csrf_field()}}
                                          </form>
                                </div>
			                        	
			                        </div>

                             
			                        
                        			
                        		</div>
                                
                            </div> <!-- end col -->

                            
                        </div>
@endsection
                        
                        
                        

                  
            
    @section('modal')        
     
    @endsection        
       

           



    
        @section('js')
<script type="text/javascript" src="{{ asset('assets/plugins/treegrid/js/jquery.treegrid.js')}}"></script>
<script type="text/javascript" src="{{ asset('assets/plugins/treegrid/js/jquery.treegrid.bootstrap3.js')}}"></script>
        <script type="text/javascript">
          $(function () {
            $('.tree').treegrid(); 
          })
        </script>
        @endsection
    
